{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-form">
            <div class="layui-form-item">
                <form action="{:url('user/finance/index')}" class="layui-form" method="get">
                <div class="layui-inline">
                    <label class="layui-form-label">时间范围</label>
                    <div class="layui-input-inline">
                        <input type="text" name="dateframe" class="layui-input" id="test16" value="{$dateframe}" autocomplete="off" >
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <select name="bxuser">
                            <option value="">请选择报销人</option>
                            {foreach name=":model('user')->where(['status'=>'1'])->select()" item="r"}
                            <option value="{$r.id}" {if condition="input('bxuser') and (input('bxuser') eq $r.id)"} selected="selected"{/if}>{$r.realname}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <select name="department">
                            <option value="">请选择部门</option>
                            {foreach name=":model('hook')->where(['group'=>'1','status'=>'1'])->select()" item="r"}
                            <option value="{$r.id}" {if condition="input('department') and (input('department') eq $r.id)"} selected="selected"{/if}>{$r.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <select name="category">
                            <option value="">请选择类目</option>
                            {foreach name=":model('hook')->where(['group'=>'2','status'=>'1'])->select()" item="r"}
                            <option value="{$r.id}" {if condition="input('category') and (input('category') eq $r.id)"} selected="selected"{/if}>{$r.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <select name="type">
                            <option value="">请选择类型</option>
                            <option value="1" {if condition="input('type') and (input('type') eq 1)"} selected="selected"{/if}>收入</option>
                            <option value="2" {if condition="input('type') and (input('type') eq 2)"} selected="selected"{/if}>支出</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layui-btn-primary ajax-search"><i class="fa fa-search"></i> 查看数据</button>
                </div>
                </form>
            </div>
        </div>
        <div class="layui-btn-group">
            <a href="{:url('user/finance/add')}" data-width="600px" data-height="585px" class="layui-btn ajax-iframe"><i class="fa fa-plus-circle"></i> 新增费用</a>
        </div>
        <blockquote class="layui-elem-quote layui-quote-nm">
            {if $dateframe}时间：<span style="color:#FF5722;font-weight: bold">{$dateframe}</span>{/if}
            累计收入：￥<span style="color:#FF5722;font-weight: bold">{$data.shouru}</span>元 
            累计支出：￥<span style="color:#FF5722;font-weight: bold">{$data.zhichu}</span>元
        </blockquote>
        <table class="layui-table layui-form" lay-filter="demo" lay-size="lg">
            <thead>
                <tr>
                    <th>日期</th>
                    <th>部门</th>
                    <th>类别</th>
                    <th>类型</th>
                    <th>金额</th>
                    <th>备注</th>
                    <th>凭证号</th>
                    <th>报销人</th>
                    <th>操作人</th>
                    <th>编辑</th>
                </tr>
            </thead>
            <tbody>
                {foreach name="list" item="v" empty="$empty"}
                <tr>
                    <td>{:date('Y-m-d',$v.datetime)}</td>
                    <td>{:model('hook')->where(['id'=>$v.department])->find()['name']}</td>
                    <td>{:model('hook')->where(['id'=>$v.category])->find()['name']}</td>
                    <td>
                        {if $v.type=='1'}
                        <button class="layui-btn layui-btn-xs layui-btn-normal">收入</button>
                        {else}
                        <button class="layui-btn layui-btn-xs layui-bg-red">支出</button>
                        {/if}                    
                    </td>
                    <td>
                        {if $v.type=='1'}
                        <button class="layui-btn layui-btn-sm layui-btn-normal">￥{:number_format($v.price,2)} 元</button>
                        {else}
                        <button class="layui-btn layui-btn-sm layui-bg-cyan">￥{:number_format($v.price,2)} 元</button>
                        {/if}
                    </td>
                    <td>{$v.remark}</td>
                    <td>{$v.voucher}</td>
                    <td>{:model('user')->where(['id'=>$v.bxuser])->value('realname')}</td>
                    <td>{:model('user')->where(['id'=>$v.userid])->value('realname')}</td>
                    <td>
                        <a href="{:url('user/finance/edit', ['id' => $v.id])}" data-width="600px" data-height="585px" class="layui-btn layui-btn-sm layui-btn-normal ajax-iframe"><i class="fa fa-edit"></i> 编辑</a>
                        <a href="{:url('user/finance/del', ['id' => $v.id])}" class="layui-btn layui-btn-sm layui-btn-danger ajax-delete"><i class="fa fa-trash-o"></i> 删除</a>
                    </td>
                </tr>
                {/foreach}
            </tbody>
        </table>
        <div class="page">{$list->render()}</div>
    </div>
</div>
{/block}
{block name="js"}
<script>
  laydate.render({
        elem: '#test16'
        ,range: '-'
  });
</script>
{/block}